SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[DISC_GetDistributorUserId]
	@DistID varchar(50)
AS
BEGIN
	SELECT TOP 1 UserID from DnnProduct_Users
	WHERE UserID IN (
		SELECT UserID FROM DnnProduct_UserProfile
		WHERE PropertyDefinitionID = (
			SELECT PropertyDefinitionID FROM DnnProduct_ProfilePropertyDefinition
			WHERE PropertyCategory = 'CDS Properties' AND PropertyName = 'DistID')
		AND PropertyValue = @DistID
	)
END
GO
